using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Perovich.GameObjects.Interfaces;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Perovich.GameObjects.TwoDimensional.Particles
{
    /// <summary>
    /// ExplosionSmokeParticleSystem is a specialization of ParticleSystem which
    /// creates a circular pattern of smoke. It should be combined with
    /// ExplosionParticleSystem for best effect.
    /// </summary>
    public class SmokeRing : ParticleSystem
    {

        /// <summary>
        /// Constructs a new instance of the <see cref="SmokeRing"/> class.
        /// </summary>
        /// <param name="game"><see cref="Perovich.GameObjects.Interfaces.ICanHoldComponents"/> instance that this <see cref="DrawableComponent"/> will be constructed for.</param>
        /// <param name="howManyEffects">How many simultaneous effects to allow at maximum.</param>
        public SmokeRing(ICanHoldComponents game, int howManyEffects)
            : base(game, howManyEffects)
        {
            Depth = 0.5f;
        }

        /// <summary>
        /// Set up the constants that will give this particle system its behavior and
        /// properties.
        /// </summary>
        protected override void InitializeConstants()
        {
            // less initial speed than the explosion itself
            minInitialSpeed = 20;
            maxInitialSpeed = 200;
            // acceleration is negative, so particles will accelerate away from the
            // initial velocity.  this will make them slow down, as if from wind
            // resistance. we want the smoke to linger a bit and feel wispy, though,
            // so we don't stop them completely like we do ExplosionParticleSystem
            // particles.
            minAcceleration = -10;
            maxAcceleration = -50;
            // explosion smoke lasts for longer than the explosion itself, but not
            // as long as the plumes do.
            minLifetime = 1.0f;
            maxLifetime = 2.5f;
            minScale = 1.0f;
            maxScale = 2.0f;
            // we need to reduce the number of particles on Windows Phone in order to keep
            // a good framerate

            MinimumParticleNumber = 15;
            MaximumParticleNumber = 30;

            minRotationSpeed = -MathHelper.PiOver4;
            maxRotationSpeed = MathHelper.PiOver4;
            blendState = BlendState.AlphaBlend;
            DrawOrder = AlphaBlendDrawOrder;
        }

        protected override void LoadContent()
        {
            texture = GameObjectsContent.Load<Texture2D>("smoke");
            base.LoadContent();
        }
    }
}
